@rem======================================================================
@rem
@rem    "kiiro.sign.binary.bat"
@rem
@rem======================================================================

@echo off

goto LInitialize


@rem----------------------------------------------------------------------
@rem    LInitialize -- Set Variables
@rem----------------------------------------------------------------------
:LInitialize
	set signtool=".\Kiiro.Tools\signtool\signtool.exe"
	set certificate=".\Kiiro.Tools\signtool\Kiiro Software Ltd.pfx"
	set keypw=646xvk
	set timestampservice="http://timestamp.verisign.com/scripts/timstamp.dll"

    goto LParseArgs


@rem----------------------------------------------------------------------
@rem    LParseArgs
@rem----------------------------------------------------------------------
:LParseArgs
	@rem --- Fix filePath ---
    set filePath=%2
    
    @rem --- Check arguments ---
	if "%filePath%" == "" (
		echo No filePath set
    )
    
	goto LMain


@rem----------------------------------------------------------------------
@rem    LMain
@rem----------------------------------------------------------------------
:LMain
	
	call :LSignBinary
	
	goto LTerminate


@rem----------------------------------------------------------------------
@rem	LSignBinary
@rem----------------------------------------------------------------------
:LSignBinary

	@rem echo
	@rem echo CommandLine: %signtool% sign /t %timestampservice% /f %certificate% /p %keypw% %filePath%
	@rem echo CurrentDirectory: %CD%
	@rem echo
	%signtool% sign /t %timestampservice% /f %certificate% /p %keypw% %filePath%
	
    goto :EOF


@rem----------------------------------------------------------------------
@rem    LTerminate
@rem----------------------------------------------------------------------
:LTerminate
	set signtool=
	set certificate=
	set keypw=
	set timestampservice=

	set filePath=